//=======================================================
// 作者：KingSley
// 描述：通过标识符防止鼠标连点导致的DOTween出错
//=======================================================
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using DG.Tweening;

namespace Babybus.Uno
{
    public class DOTweenTouchTime : MonoBehaviour
    {
        //Sequence mySequence;
        //Tweener myTweener;
        bool isPlay;

        void Start()
        {
            isPlay = false;

            //myTweener = transform.DOScale(new Vector3(3, 3, 3), 0.5f).OnComplete(ReStart);
            //myTweener.SetAutoKill(false);
            //myTweener.Pause();
            //mySequence = DOTween.Sequence();// 创建空序列  
            //Tweener Scale1 = transform.DOScale(new Vector3(3, 3, 3), 0.5f);
            //Tweener Scale2 = transform.DOScale(new Vector3(1, 1, 1), 0.5f).OnComplete(ReStart); 
            //mySequence.Append(Scale1);
            //mySequence.Append(Scale2);
            //mySequence.SetAutoKill(false);// 不自动消失掉动画
            //mySequence.Pause();
        }

        private void LateScale()
        {
            transform.DOScale(new Vector3(1, 1, 1), 0.5f).OnComplete(ReStart);
        }

        private void ReStart()
        {
            isPlay = false;
        }

        void Update()
        {
            if (Input.GetMouseButton(0))
            {
                if (!isPlay)
                {
                    isPlay = true;
                    //mySequence.Play(); // 开始播放
                    transform.DOScale(new Vector3(3, 3, 3), 0.5f).OnComplete(LateScale);
                }
            }
        }
    }
}
